package ivan.cheng.utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PermissionInfo;

public class Util {
	public static int GetWarningPermissionCount(PackageInfo pi,
			PackageManager pm) {
		int q = 0, w = 0, e = 0, r = 0, t = 0;
		for (String sp : pi.requestedPermissions) {
			try {
				int protectionLevel = pm.getPermissionInfo(sp, 0).protectionLevel;
				switch (protectionLevel) {
				case PermissionInfo.PROTECTION_NORMAL:
					q++;
					break;
				case PermissionInfo.PROTECTION_DANGEROUS:
					w++;
					break;
				case PermissionInfo.PROTECTION_SIGNATURE:
					e++;
					break;
				case PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM:
					r++;
					break;
				default:
					sp.toString();
					break;
				}
			} catch (NameNotFoundException e1) {
				e1.printStackTrace();
				LogUtil.w("NameNotFoundException:" + sp);
				t++;
			}
		}
		return w;
	}
}
